package myJs

import myJs.{App, Main}
import myJs.myPkg.{NProgress, NavigateOptions}
import myJs.myPkg.jquery._
import myJs.tool.Tool
import org.scalajs.dom.{document, window}
import slinky.core.{Component, FunctionalComponent}
import slinky.core.annotations.react
import slinky.core.facade.{ReactElement, ReactRef}
import slinky.web.html._
import myJs.Implicits._
import slinky.core.facade.Hooks.useEffect

import scala.scalajs.js

/**
 * Created by yz on 21/1/2022
 */
@react object CpLayer {

  case class Props(title: String, children: ReactElement)

  val component = FunctionalComponent[Props] { props =>

    useEffect(() => {
      startLoad
      Tool.selectLeft
      document.title = s"${props.title}-样本管理系统"
      loadComplete
      val minHeight=(window.innerHeight-46-35-33).toInt
      $(".page-content").css("min-height",s"${minHeight}px")
    }, List()
    )

    div(
      props.children
    )

  }

  def startLoad = {
    NProgress.start()
  }

  def loadComplete = {
    NProgress.done()
  }

}
